﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Serialization;

namespace BDSim
{
    /// <summary>
    /// 空间环境
    /// </summary>
    public class SpaceEnvModel : EnvBaseModel
    {
        #region 字段和属性
        /// <summary>
        /// 空间环境中的模型列表
        /// </summary>
        private ObservableCollection<SpaceEnvModel> _SpaceEnvModelList = new ObservableCollection<SpaceEnvModel>();
        [XmlAttribute, Browsable(false)]
        public ObservableCollection<SpaceEnvModel> SpaceEnvModelList
        {
            get { return _SpaceEnvModelList; }
            set { _SpaceEnvModelList = value; NotifyPropertyChanged("SpaceEnvModelList"); }
        }

        /// <summary>
        /// 使能开关，模型默认状态是可用的，设为true
        /// </summary>        
        private bool _Enabled = true;
        [XmlAttribute, CategoryAttribute("模型设置"), DescriptionAttribute("模型使能开关，默认true打开")]
        public bool Enabled
        {
            get { return _Enabled; }
            set { _Enabled = value; }
        }

        /// <summary>
        /// 时间间隔
        /// </summary>
        private double _time_interval;
        [XmlAttribute, CategoryAttribute("模型设置"), DescriptionAttribute("模型数值计算时间间隔，单位秒(s)，默认间隔1小时")]
        public double IntervalTime
        {
            get { return _time_interval; }
            set { _time_interval = value; }
        }

        /// <summary>
        /// 坐标间隔
        /// </summary>
        private IntervalBLHClass _blh_interval = new IntervalBLHClass();
        [XmlAttribute, CategoryAttribute("模型设置"), TypeConverter(typeof(PropertySorter)), DescriptionAttribute("模型数值计算坐标间隔，单位度")]
        public IntervalBLHClass IntervalBLH
        {
            get { return _blh_interval; }
            set { _blh_interval = value; }
        }

        #endregion

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        public SpaceEnvModel()
        {
            _time_interval = 3600;      //时间默认间隔3600s
            _blh_interval.B = 5;        //纬度默认间隔5度
            _blh_interval.L = 10;       //经度默认间隔10度
            _blh_interval.H = 1000;     //高度默认间隔1000m
        }

        #endregion

        #region 方法
        /// <summary>
        /// 初始化函数
        /// </summary>
        public override bool Init()
        {
            foreach (var item in SpaceEnvModelList)
            {
                item.Init();
            }
            return true;
        }

        #endregion
    }
}
